home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / relay / anews / b.to.a < prev    next >
Text File  |  1989-06-27  |  798b  |  37 lines

  1. #! /bin/sh
  2. # bnewstoa: B-format news to A-format converter (why, oh, why?) (thanks, Norman
  3.  
  4. PATH=/bin:/usr/bin:/usr/ucb; export PATH
  5.  
  6. awk '
  7. NR==1,/^$/    {        # headers: save A headers only
  8.     if ($0 ~ /^Message-ID: /)
  9.         msgid=$2
  10.     else if ($0 ~ /^Newsgroups: /)
  11.         ngs=$2
  12.     else if ($0 ~ /^Path: /)
  13.         path=$2
  14.     else if ($0 ~ /^Date: /) {
  15.         date = $2    # skip "Date:"
  16.         for (i = 3; i <= NF; i++)
  17.             date = date " " $i    # append remaining fields
  18.     } else if ($0 ~ /^Subject: /)
  19.         subj=$2
  20.     else if ($0 ~ /^$/) {    # end of headers: spew out A-format equivalent
  21.         print "A" msgid
  22.         print ngs
  23.         print path
  24.         print date
  25.         print subj
  26.         inbody = "yes"
  27.         noblanksyet = "yes"
  28.     }
  29. }
  30. inbody=="yes"    {    # copy body except first blank line, if present
  31.     if ($0 ~ /^$/ && noblanksyet == "yes")
  32.         noblanksyet = "no"
  33.     else
  34.         print
  35. }
  36. '
  37.